#! /bin/bash
cd $(dirname $0)
ROOT_DIR=$(cd .. && pwd)

cd $ROOT_DIR

# 编译本地版本
go build -o frigate ./cmd/main.go

rm -rf bin && mkdir -p bin
# 交叉编译到 Linux x86_64 架构
export CGO_ENABLED=0
export GOOS=linux
export GOARCH=amd64
go build -o ./bin/frigate_${GOOS}_${GOARCH} ./cmd/main.go

# 交叉编译到 Linux arm64 架构 
export GOARCH=arm64
go build -o ./bin/frigate_${GOOS}_${GOARCH} ./cmd/main.go

# 恢复本地环境变量
unset GOOS
unset GOARCH
unset CGO_ENABLED

ls -alh ./bin
